package cn.wolfcode.p2p.service.impl;

import cn.wolfcode.p2p.business.service.IBidRequestService;
import cn.wolfcode.p2p.business.service.IPaymentScheduleDetailService;
import cn.wolfcode.p2p.business.service.IPaymentScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 系统定时任务
 */
@Component
public class ScheduledTask {

    @Autowired
    private IBidRequestService bidRequestService;
    @Autowired
    private IPaymentScheduleService paymentScheduleService;

    /**
     * 每隔十秒,做测试用
     * 定义一个定时器(间隔时间大一点),专门负责查询数据库中的代发标,放入队列(存在重复放入问题)
     */
    @Scheduled(cron = "*/10 * * * * ?")
    public void publishBidRequestToQueue() {

        bidRequestService.publishBidRequestToQueue();
    }


    /**
     * 每隔10秒检查定时发标
     */
    @Scheduled(cron = "*/10 * * * * ?")
    public void publishBidRequestCheck() {

        bidRequestService.publishBidRequestCheck();
    }

    /**
     * 每天晚上12点定时做滞纳金检查
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void overdueAmountCheck(){
        paymentScheduleService.overdueAmountCheck();
    }

}
